/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
//FIXME staviti svuda labele sa signalima!!!
/*
 * InterArbitrator.java
 *
 * Created on Sep 29, 2011, 10:51:39 AM
 */
package aor2.gui.cpu;

import aor2.cpu.blockinterface.Arbitrator;
import aor2.systembus.SystemBus;
import java.awt.Graphics;

/**
 * 
 * @author Yogi
 */
public class InterArbitrator extends javax.swing.JPanel {
	private static InterArbitrator singleton = null;

	public static InterArbitrator getInstance() {
		if (singleton == null)
			singleton = new InterArbitrator();
		return singleton;
	}

	private JLabelSet BusyBus, BR, BG;

	private void makeSignals() {
		BusyBus = new JLabelSet(false, BusyBus1, BusyBus2, BusyBus3, BusyBus4);
		BR = new JLabelSet(false, BR1, BR2, BR3);
		BG = new JLabelSet(false, BG1, BG2, BG3, BG4, BG5);
	}

	/** Creates new form InterArbitrator */
	public InterArbitrator() {
		initComponents();
		makeSignals();
	}

	@Override
	protected void paintComponent(Graphics g) {
		BusyBus.setEnabled(SystemBus.getInstance().getBusybus());
		BG.setEnabled(Arbitrator.getInstance().getBgs()[3].isActive());
		BR.setEnabled(Arbitrator.getInstance().getBrs()[3].isActive());
		super.paintComponent(g);
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed"
	// desc="Generated Code">//GEN-BEGIN:initComponents
	private void initComponents() {
		java.awt.GridBagConstraints gridBagConstraints;

		jLayeredPane1 = new javax.swing.JLayeredPane();
		BusyBus1 = new javax.swing.JLabel();
		BusyBus2 = new javax.swing.JLabel();
		BusyBus3 = new javax.swing.JLabel();
		BusyBus4 = new javax.swing.JLabel();
		BR1 = new javax.swing.JLabel();
		BR2 = new javax.swing.JLabel();
		BR3 = new javax.swing.JLabel();
		BG1 = new javax.swing.JLabel();
		BG2 = new javax.swing.JLabel();
		BG3 = new javax.swing.JLabel();
		BG4 = new javax.swing.JLabel();
		BG5 = new javax.swing.JLabel();
		jLabel1 = new javax.swing.JLabel();

		setBackground(new java.awt.Color(255, 255, 255));
		setLayout(new java.awt.GridBagLayout());

		BusyBus1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_1.jpg"))); // NOI18N
		BusyBus1.setDisabledIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/aor2/common/resources/vert_1pt_0.jpg"))); // NOI18N
		BusyBus1.setEnabled(false);
		BusyBus1.setBounds(20, 13, 34, 495);
		jLayeredPane1.add(BusyBus1, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BusyBus2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BusyBus2.setDisabledIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BusyBus2.setEnabled(false);
		BusyBus2.setBounds(20, 80, 106, 7);
		jLayeredPane1.add(BusyBus2, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BusyBus3.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BusyBus3.setDisabledIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BusyBus3.setEnabled(false);
		BusyBus3.setBounds(20, 270, 106, 7);
		jLayeredPane1.add(BusyBus3, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BusyBus4.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BusyBus4.setDisabledIcon(new javax.swing.ImageIcon(getClass()
				.getResource("/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BusyBus4.setEnabled(false);
		BusyBus4.setBounds(20, 420, 98, 7);
		jLayeredPane1.add(BusyBus4, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BR1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BR1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BR1.setEnabled(false);
		BR1.setBounds(229, 421, 53, 14);
		jLayeredPane1.add(BR1, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BR2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		BR2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_1.jpg"))); // NOI18N
		BR2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_0.jpg"))); // NOI18N
		BR2.setEnabled(false);
		BR2.setBounds(275, 308, 14, 121);
		jLayeredPane1.add(BR2, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BR3.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BR3.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BR3.setEnabled(false);
		BR3.setBounds(281, 301, 36, 14);
		jLayeredPane1.add(BR3, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BG1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BG1.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BG1.setEnabled(false);
		BG1.setBounds(89, 445, 29, 14);
		jLayeredPane1.add(BG1, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BG2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		BG2.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_1.jpg"))); // NOI18N
		BG2.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_0.jpg"))); // NOI18N
		BG2.setEnabled(false);
		BG2.setBounds(82, 452, 14, 43);
		jLayeredPane1.add(BG2, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BG3.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BG3.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BG3.setEnabled(false);
		BG3.setBounds(88, 488, 567, 14);
		jLayeredPane1.add(BG3, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BG4.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		BG4.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_1.jpg"))); // NOI18N
		BG4.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/vert_1pt_0.jpg"))); // NOI18N
		BG4.setEnabled(false);
		BG4.setBounds(646, 308, 14, 188);
		jLayeredPane1.add(BG4, javax.swing.JLayeredPane.DEFAULT_LAYER);

		BG5.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_1.jpg"))); // NOI18N
		BG5.setDisabledIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/horiz_1pt_0.jpg"))); // NOI18N
		BG5.setEnabled(false);
		BG5.setBounds(629, 301, 25, 14);
		jLayeredPane1.add(BG5, javax.swing.JLayeredPane.DEFAULT_LAYER);

		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		add(jLayeredPane1, gridBagConstraints);

		jLabel1.setBackground(new java.awt.Color(255, 255, 255));
		jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource(
				"/aor2/common/resources/arbitrator1.jpg"))); // NOI18N
		gridBagConstraints = new java.awt.GridBagConstraints();
		gridBagConstraints.gridx = 0;
		gridBagConstraints.gridy = 0;
		gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
		gridBagConstraints.weightx = 1.0;
		gridBagConstraints.weighty = 1.0;
		add(jLabel1, gridBagConstraints);
	}// </editor-fold>//GEN-END:initComponents
		// Variables declaration - do not modify//GEN-BEGIN:variables

	private javax.swing.JLabel BG1;
	private javax.swing.JLabel BG2;
	private javax.swing.JLabel BG3;
	private javax.swing.JLabel BG4;
	private javax.swing.JLabel BG5;
	private javax.swing.JLabel BR1;
	private javax.swing.JLabel BR2;
	private javax.swing.JLabel BR3;
	private javax.swing.JLabel BusyBus1;
	private javax.swing.JLabel BusyBus2;
	private javax.swing.JLabel BusyBus3;
	private javax.swing.JLabel BusyBus4;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLayeredPane jLayeredPane1;
	// End of variables declaration//GEN-END:variables
}
